﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Infrastructure.Dispatcher
{
    /// <summary>
    /// 调度任务
    /// </summary>
    public class DispatcherTask
    {
        /// <summary>
        /// 任务集合
        /// </summary>
        Task[] tasks;

        public DispatcherTask(params Task[] tasks) {
            this.tasks = tasks;
        }

        public void Run() {
            if (tasks != null && tasks.Length > 0) {
                tasks[0].Start();
                Task.WaitAll(tasks);
                tasks.ToList().ForEach(t => t.Dispose());
            }
        }
    }
}
